/*
 * @Description: 代码定义reducer
 * @Author: Rfan
 * @Date: 2022-01-08 16:30:05
 * @LastEditTime: 2022-02-15 10:40:45
 */

import { insertItem } from '@/utils/list';
import { ADD_FONT } from '../constants';

export const CodeDefReducer = (state, action) => {
  switch (action.type) {
    /**
     * @description: 添加代码定义
     * @param {Object} data 新增的代码定义
     */
    case ADD_FONT:
      return {
        ...state,
        list: insertItem(action.data, state.list),
        dialog: { visible: false }
      };

    default:
      console.log('untouched', action);
      return state;
  }
};
